package com.ihr360.payroll.scheduler;

import com.ihr360.job.endpoint.PoolStatus;
import com.ihr360.job.endpoint.ThreadPoolStatus;
import com.ihr360.payroll.service.batch.BatchExecuatorStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class TaskPoolStatusScheduler {

    @Autowired
    private ThreadPoolStatus threadPoolStatus;
    @Autowired
    BatchExecuatorStatusService batchExecuatorStatusService;

    @Scheduled(fixedDelay = 10000)
    private void syncServiceProfileInfo() {
        PoolStatus poolStatus = threadPoolStatus.getPoolStatus();
        batchExecuatorStatusService.updateStatus(poolStatus);
    }

    @Scheduled(fixedDelay = 30000)
    private void removeUnused() {
        batchExecuatorStatusService.clearOutdateExecuator();
    }

}
